import Request from "luch-request";
const http = new Request();
http.setConfig((config) => {
	config.sslVerify = false
	// #ifdef H5
	config.baseURL = '/others'
	// #endif
	// #ifndef H5
	config.baseURL = "https://ssjh.jifenma.com"
	// #endif
	return config;
});
const header = {
	"Content-Type": "application/x-www-form-urlencoded"
};

class ServerWallet {
	constructor() {
		this.getWalletGasPriceApi = "/api/wallet/get_gas_price",
		this.getTokenPriceApi = "/api/wallet/get_token_price",
		this.gethistoryApi = "/api/wallet/get_transaction_history",
		this.getBalanceApi = "/api/wallet/get_balance",
		this.getConfigApi = "/api/wallet/getconfig",
		this.getversionApi = "/api/wallet/getversion"
	}
	getWalletGasPrice(data) {
		return http.post(this.getWalletGasPriceApi, null, {
			header
		}).then((res) => res.data);
	}
	getTokenPrice() {
		return http.post(this.getTokenPriceApi, null, {
			header
		}).then((res) => res.data);
	}
	getHistory(data) {
		return http.post(this.gethistoryApi, {
			params: data
		}, {
			header
		}).then((res) => res.data);
	}
	getConfig(app_id, config_type) {
		return http.post(this.getConfigApi, {
			params: {
				config_type
			}
		}, {
			header
		}).then((res) => res.data);
	}
	getBalance(data) {
		return http.post(this.getBalanceApi, data).then((res) => res.data);
	}
	fetchAppUrl(app_id,config_type) {
		return http.post(this.getversionApi, {
			params: {
				config_type
			}
		}, {
			header
		}).then((res) => res.data);
	}
}
export const ServerWalletApi = new ServerWallet();